package LeiHeiDuiXiang.LeiHeDuiXiang1;

public class Date {
    public int year;
    public int month;
    public int day;

    public Date(){
        //this.year=2008;
        this(2021,1,1);
        System.out.println("这个是不带参数的构造方法");
    }

    public Date(int year,int month,int day){
        //this();
        this.year=year;
        this.month=month;
        this.day=day;
        System.out.println("调用了带有3个参数的构造方法");
    }

    //写一个方法设置年月日
    public void setDate(int year,int month,int day){
        this.year=year;
        this.month=month;
        this.day=day;
    }

    //打印年月日
    public void printDate(){
        System.out.println(this.year+"年"+
                this.month+"月"+
                this.day+"日");
    }

    public  void test(){
        System.out.println("测试一下this");
    }

    public static void main(String[] args) {
        Date date=new Date(2012,12,12);
        date.printDate();
       // System.out.println(this.year);

        Date date1=new Date();
        date1.setDate(2012,9,9);
        date1.printDate();

        Date date2=new Date();//new一个对象的时候，同时也调用了该构造函数
        //date2.setDate(2008,8,8);
        date2.printDate();

        Date date3=new Date();
        date3.setDate(2009,9,9);
        date3.printDate();
    }
}
